//
//  BaseViewController.swift
//  Wallpaper
//
//  Created by    on 2023/12/19.
//

import UIKit

class BaseViewController: UIViewController {
    lazy var backBtn : UIButton = {
        let btn : UIButton = UIButton(type: .custom)
        btn.setImage(UIImage(named: "back_icon")?.withRenderingMode(.alwaysOriginal), for: .normal)
        btn.addTarget(self, action: #selector(back), for: .touchUpInside)
        return btn
    }()
    
    @objc func back() {
        self.navigationController?.popViewController(animated: true)
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        view.translatesAutoresizingMaskIntoConstraints = true
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = mainColor
        self.navigationItem.backBarButtonItem = UIBarButtonItem(customView: backBtn)
        self.navigationController?.navigationBar.tintColor = UIColor.white
        if #available(iOS 15.0, *) {
            let appearnce = UINavigationBarAppearance()
            appearnce.configureWithOpaqueBackground()
            appearnce.backgroundColor = mainColor
            appearnce.titleTextAttributes = [.foregroundColor:UIColor.white]
            self.navigationController?.navigationBar.standardAppearance = appearnce
            self.navigationController?.navigationBar.scrollEdgeAppearance = appearnce
        }
        self.addSubViews()
    }
    
    
    func addSubViews(){
        
    }
}
